<html>
<head><meta charset="utf-8"><title>Reusing RLS name resolution · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html">Reusing RLS name resolution</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226272614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226272614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226272614">(Feb 13 2021 at 22:31)</a>:</h4>
<p>Hi! I have a quick question, is the RLS name resolution anywhere close to usuable as a library? Or is it too tied into the RLS internals?</p>



<a name="226272714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226272714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226272714">(Feb 13 2021 at 22:33)</a>:</h4>
<p>really, I only need to resolve <code>Item</code>s (function names, type / constructors, etc)</p>



<a name="226272757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226272757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226272757">(Feb 13 2021 at 22:34)</a>:</h4>
<p>RLS uses rustc's name resolution, rust-analyzer does it in its <code>hir_def</code> crate, which currently is relatively closely tied to its internals</p>



<a name="226272760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226272760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226272760">(Feb 13 2021 at 22:34)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/issues/5922">https://github.com/rust-analyzer/rust-analyzer/issues/5922</a> tracks refactoring it to make it more architecture-independent</p>



<a name="226273782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226273782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226273782">(Feb 13 2021 at 23:00)</a>:</h4>
<p>huh i cant believe i hadn't heard of <code>rustc_save_analysis</code></p>



<a name="226273790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226273790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226273790">(Feb 13 2021 at 23:01)</a>:</h4>
<p>I'm not sure if the info it provides is enough but it might work....</p>



<a name="226273855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226273855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226273855">(Feb 13 2021 at 23:03)</a>:</h4>
<p>that RA issue seems super interesting</p>



<a name="226273886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/226273886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#226273886">(Feb 13 2021 at 23:03)</a>:</h4>
<p>though in either case I need to also get the types for the names once I've resolved them so I might just be stuck with talking directly to rustc</p>



<a name="227393302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Reusing%20RLS%20name%20resolution/near/227393302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Reusing.20RLS.20name.20resolution.html#227393302">(Feb 23 2021 at 07:55)</a>:</h4>
<p><span class="user-mention" data-user-id="312719">@Xavier Denis</span> You can use the rust-analyzer hir as lib to resolve stuff. All these crates are being published and <code>cargo-modules</code> is a good example</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>